package com.ruoyi.yzd.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yzd.domain.YzdCorporation;
import com.ruoyi.yzd.service.IYzdCorporationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 易制毒-法人Controller
 * 
 * @author zyb
 * @date 2023-07-04
 */
@RestController
@RequestMapping("/access/corporation")
public class YzdCorporationController extends BaseController
{
    @Autowired
    private IYzdCorporationService yzdCorporationService;

    /**
     * 查询易制毒-法人列表
     */
    @PreAuthorize("@ss.hasPermi('access:corporation:list')")
    @GetMapping("/list")
    public TableDataInfo list(YzdCorporation yzdCorporation)
    {
        startPage();
        List<YzdCorporation> list = yzdCorporationService.selectYzdCorporationList(yzdCorporation);
        return getDataTable(list);
    }

    /**
     * 导出易制毒-法人列表
     */
    @PreAuthorize("@ss.hasPermi('access:corporation:export')")
    @Log(title = "易制毒-法人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YzdCorporation yzdCorporation)
    {
        List<YzdCorporation> list = yzdCorporationService.selectYzdCorporationList(yzdCorporation);
        ExcelUtil<YzdCorporation> util = new ExcelUtil<YzdCorporation>(YzdCorporation.class);
        util.exportExcel(response, list, "易制毒-法人数据");
    }

    /**
     * 获取易制毒-法人详细信息
     */
    @PreAuthorize("@ss.hasPermi('access:corporation:query')")
    @GetMapping(value = "/{corporationId}")
    public AjaxResult getInfo(@PathVariable("corporationId") String corporationId)
    {
        return success(yzdCorporationService.selectYzdCorporationByCorporationId(corporationId));
    }

    /**
     * 新增易制毒-法人
     */
    @PreAuthorize("@ss.hasPermi('access:corporation:add')")
    @Log(title = "易制毒-法人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YzdCorporation yzdCorporation)
    {
        return toAjax(yzdCorporationService.insertYzdCorporation(yzdCorporation));
    }

    /**
     * 修改易制毒-法人
     */
    @PreAuthorize("@ss.hasPermi('access:corporation:edit')")
    @Log(title = "易制毒-法人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YzdCorporation yzdCorporation)
    {
        return toAjax(yzdCorporationService.updateYzdCorporation(yzdCorporation));
    }

    /**
     * 删除易制毒-法人
     */
    @PreAuthorize("@ss.hasPermi('access:corporation:remove')")
    @Log(title = "易制毒-法人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{corporationIds}")
    public AjaxResult remove(@PathVariable String[] corporationIds)
    {
        return toAjax(yzdCorporationService.deleteYzdCorporationByCorporationIds(corporationIds));
    }
}
